package com.app.micaihu.view.army.adapter

import android.annotation.SuppressLint
import android.widget.ImageView
import android.widget.SeekBar
import com.app.micaihu.R
import com.app.micaihu.view.bean.Mission
import com.app.micaihu.view.bean.MissionX
import com.app.micaihu.view.utils.loadImage
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * 军团任务列表适配器
 */
class ArmyTaskListAdapter : BaseQuickAdapter<MissionX, BaseViewHolder>(R.layout.army_task_list_item) {

    @SuppressLint("ClickableViewAccessibility")
    override fun convert(holder: BaseViewHolder, item: MissionX) {
        holder.apply {
            getView<ImageView>(R.id.ivTaskIcon).loadImage(item.taskIcon, R.drawable.user_head_def)
            setText(R.id.tvTaskName, item.taskName)
            setText(R.id.tvTaskGold, "+${item.taskGold}")
            setText(R.id.tvProgress, "${item.taskCurrentProgress}/${item.taskAllProgress}")
            val barTask = getView<SeekBar>(R.id.barTask)
            barTask.max = item.taskAllProgress
            barTask.progress = item.taskCurrentProgress
            barTask.setOnTouchListener { v, event -> true }
            setText(R.id.tvTaskFinish, item.taskBtn)

        }
    }

}